package goutl

import (
	"gitee.com/xiakai001/goutl/constraints"
	"strconv"
)

func Max[V constraints.Number](a V, b ...V) V {

	for _, _b := range b {
		if a < _b {
			a = _b
		}
	}

	return a
}

func Min[V constraints.Number](a V, b ...V) V {
	for _, _b := range b {
		if a > _b {
			a = _b
		}
	}

	return a
}

func Abs[V constraints.Number](a V) V {

	if a > 0 {
		return a
	}

	return -a
}

func ParseIntToStr[V constraints.Integer](a V) string {
	return strconv.FormatInt(int64(a), 10)
}

func ParseFloatToStr[V constraints.Float](a V) string {
	return strconv.FormatFloat(float64(a), 'f', -1, 64)
}
